package com.teamwings.modules.page.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.teamwings.ctrls.entity.DatabaseTableWithColumns;
import com.teamwings.modules.code.entity.FormTableCode;
import com.teamwings.modules.page.vo.FormDataVo;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  表单设计服务类
 * </p>
 *
 * @author admin
 * @since 2021-05-06
 */
public interface IPageService {

    String getTableNameById(String formId);

    Map<String, Object> show(String formId, String id);

    String add(FormDataVo formDataVo);

    void edit(FormDataVo formDataVo);

    void remove(String formId, String id);

    @Deprecated
    IPage<Map<String, String>> selectPage(Page<Map<String, String>> formDataPage, Wrapper<?> wrapper);

    String getTableCodeBy(String formId,Integer version);

    IPage<Map<String, String>> selectPageByQueryGenerator(String formId, Long page, Long pageSize, QueryWrapper<?> wrapper);

    IPage<Map<String, String>> selectPageByRecordsWithFields(String formId, Long page, Long pageSize,
                                                             QueryWrapper<?> queryWrapper, String fields);

    void saveByFormId(String tableName, Map<String, String> formData);

    IPage<Map<String, String>> selectPageByRecords(String formId, Long page, Long pageSize, QueryWrapper<?> queryWrapper);

    IPage<Map<String, String>> selectPageByRecords(String formId, Long page, Long pageSize, QueryWrapper<?> queryWrapper, Boolean hasFormId);

    List<Map<String, String>> selectAllRecords(String formId);

    IPage<Map<String, String>> selectPageByRecordsWithFields(
            String formId,
            Long page,
            Long pageSize,
            QueryWrapper<?> queryWrapper,
            String fields,
            Boolean hasFormId
    );

    int update(String tableName, Map<String, String> formData);

    List<Map> executeSql(String sql);

    List<FormTableCode> getTableCodeVersionByHeadId(String formId);

    List<String> getColumnByTableName(String tableName);

    IPage<Map<String, String>> selectRecordsBySql(
            String sql,
            Long page,
            Long pageSize,
            QueryWrapper<?> queryWrapper,
            Boolean hasWhere
    );

    List<Map<String, Object>> selectBySql(
            String sql,
            QueryWrapper<?> queryWrapper,
            Boolean hasWhere
    );

    JdbcTemplate getJdbcTemplate();

    List<Map<String, Object>> querySql(String sql, Map<String, Object> params);

    String getTableCodeByFormId(String formId);

    List<Map> selectFields(String fields, String tableName);

    List<Map<String, Object>> selectAll(String tableName, Wrapper<?> wrapper);

    Boolean repeat(String formId, String id, String field, String value);

    DatabaseTableWithColumns getTableWithColumns(String formId);

    FormTableCode getLatestOneByFormId(String formId);

    Map<String, String> getTypeMap(String formId);

    List<Map> selectFields2(String fields, String tableName, Wrapper<?> wrapper);
}
